clear all
set mem 100m

local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"
local path1="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\outregs"


cd "`path0'Workfiles\"

set more off
use completed_data, clear

gen LTG_1500= LNmaddison2001-LNmaddison1500
gen LTG_1820= LNmaddison2001-LNmaddison1820
label var LTG_1500 "Maddison: Cumulative log growth between 1500 and 2001"
label var LTG_1820 "Maddison: Cumulative log growth between 1820 and 2001"


twoway (scatter LTG_1500 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", mlabel(countrycode)) ///
		   (lfit LTG_1500 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"), ///
		   legend(off) ytitle("Maddison: Log GDP per capita growth, 1500-2001")
		   
twoway (scatter LTG_1820 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", mlabel(countrycode)) ///
		   (lfit LTG_1820 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"), ///
		   legend(off) ytitle("Maddison: Log GDP per capita growth, 1820-2001")
		
twoway (scatter LNmaddison1500 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", mlabel(countrycode)) ///
		   (lfit LNmaddison1500 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"), ///
		   legend(off) ytitle("Maddison: Log GDP per capita, 1500")
		   
		   
* initial conditions
reg LNmaddison1500 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"

reg LNmaddison2001 LNmaddison1500 if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"
reg LNmaddison2001 LNmaddison1820 if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"

reg LNmaddison1500 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"
reg LNmaddison1500 icrg_ERR_mean if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"
reg LNmaddison1500 idv icrg_ERR_mean if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG"


* plain regressions
	reg LTG_1500 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust 
	outreg2 idv using "`path1'\LTG_1500.txt" , ///
		replace bdec(3) rdec(3) aster nocons nolabel ctitle("OLS") 
		
	reg LTG_1820 idv if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust 
	outreg2 idv using "`path1'\LTG_1820.txt" , ///
		replace bdec(3) rdec(3) aster nocons nolabel ctitle("OLS") 
		
		
* plain regressions with standard controls
	reg LTG_1500 idv landlocked abs_long abs_lati if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust 
	outreg2 idv using "`path1'\LTG_1500.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: controls") 
		
	reg LTG_1820 idv landlocked abs_long abs_lati if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust 
	outreg2 idv using "`path1'\LTG_1820.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: controls") 
	
* plain regressions with continent dummies
	xi: reg LTG_1500 idv i.continent  if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust 
	outreg2 idv using "`path1'\LTG_1500.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS:  cont dummies") 
		
	xi: reg LTG_1820 idv i.continent  if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust 
	outreg2 idv using "`path1'\LTG_1820.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: cont dummies") 
	
* control for institutions
	reg LTG_1500 idv icrg_ERR_mean if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust 
	outreg2 idv icrg_ERR_mean using "`path1'\LTG_1500.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS:  institution") 
		
		
	reg LTG_1820 idv icrg_ERR_mean if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust 
	outreg2 idv icrg_ERR_mean using "`path1'\LTG_1820.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("OLS: institution") 
	
	
*=========================================================================	
	
* plain regressions
	ivreg2 LTG_1500 (idv = distM_UK) if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\LTG_1500.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	ivreg2 LTG_1820 (idv = distM_UK) if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\LTG_1820.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
* plain regressions with standard controls
	ivreg2 LTG_1500 landlocked abs_long abs_lati (idv = distM_UK) if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\LTG_1500.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
	ivreg2 LTG_1820  landlocked abs_long abs_lati (idv = distM_UK) if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\LTG_1820.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
		
* plain regressions with continent dummies
	xi: ivreg2 LTG_1500 i.continent  (idv = distM_UK) if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\LTG_1500.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	xi: ivreg2 LTG_1820 i.continent  (idv = distM_UK) if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv using "`path1'\LTG_1820.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	
* control for institutions
	ivreg2 LTG_1500 icrg_ERR_mean (idv = distM_UK) if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv icrg_ERR_mean using "`path1'\LTG_1500.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		
	ivreg2 LTG_1820 icrg_ERR_mean (idv = distM_UK) if pwt_ln_rgdpwok~=. & countrycode~="SGP" & countrycode~="TWN" & countrycode~="HKG", robust ffirst
	matrix A=e(first)
	local R2first=A[2,1]
	local Ffirst =A[3,1]
	outreg2 idv icrg_ERR_mean using "`path1'\LTG_1820.txt" , ///
		append bdec(3) rdec(3) aster nocons nolabel ctitle("IV") ///
		addstat("1st stage F-stat", `Ffirst',"Partial R2",`R2first')
		


	
	
	
				
	
